package cn.itcast.service.impl;

import cn.itcast.dao.CountyDao;
import cn.itcast.domain.County;
import cn.itcast.service.CountyService;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("countyService")
public class CountyServiceImpl implements CountyService {

    @Override
    public List<County> findCity(String key) throws Exception {
        SqlSession sqlSession = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("SqlMapConfig.xml.bak")).openSession();
        CountyDao countyDao = sqlSession.getMapper(CountyDao.class);
        key = "%"+key+"%";
        System.out.println(key);
        return countyDao.findCity(key);
    }
}
